//tree型json转换
export const transData = (a, idStr, pidStr) => {
    var r = [],
      hash = {},
      id = idStr,
      pid = pidStr,
      i = 0,
      j = 0,
      len = a.length;
  
    for (; i < len; i++) {
      hash[a[i][id]] = a[i];
    }
  
    for (; j < len; j++) {
      var aVal = a[j],
        hashVP = hash[aVal[pid]];
  
      if (hashVP) {
        !hashVP['children'] && (hashVP['children'] = []);
  
        hashVP['children'].push(aVal);
      } else {
        r.push(aVal);
      }
    }
  
    return r;
  };
  //us state
export const usStates =  [
  {
    "ID": "1",
    "STATE_CODE": "AL",
    "STATE_NAME": "Alabama"
  },
  {
    "ID": "2",
    "STATE_CODE": "AK",
    "STATE_NAME": "Alaska"
  },
  {
    "ID": "3",
    "STATE_CODE": "AZ",
    "STATE_NAME": "Arizona"
  },
  {
    "ID": "4",
    "STATE_CODE": "AR",
    "STATE_NAME": "Arkansas"
  },
  {
    "ID": "5",
    "STATE_CODE": "CA",
    "STATE_NAME": "California"
  },
  {
    "ID": "6",
    "STATE_CODE": "CO",
    "STATE_NAME": "Colorado"
  },
  {
    "ID": "7",
    "STATE_CODE": "CT",
    "STATE_NAME": "Connecticut"
  },
  {
    "ID": "8",
    "STATE_CODE": "DE",
    "STATE_NAME": "Delaware"
  },
  {
    "ID": "9",
    "STATE_CODE": "DC",
    "STATE_NAME": "District of Columbia"
  },
  {
    "ID": "10",
    "STATE_CODE": "FL",
    "STATE_NAME": "Florida"
  },
  {
    "ID": "11",
    "STATE_CODE": "GA",
    "STATE_NAME": "Georgia"
  },
  {
    "ID": "12",
    "STATE_CODE": "HI",
    "STATE_NAME": "Hawaii"
  },
  {
    "ID": "13",
    "STATE_CODE": "ID",
    "STATE_NAME": "Idaho"
  },
  {
    "ID": "14",
    "STATE_CODE": "IL",
    "STATE_NAME": "Illinois"
  },
  {
    "ID": "15",
    "STATE_CODE": "IN",
    "STATE_NAME": "Indiana"
  },
  {
    "ID": "16",
    "STATE_CODE": "IA",
    "STATE_NAME": "Iowa"
  },
  {
    "ID": "17",
    "STATE_CODE": "KS",
    "STATE_NAME": "Kansas"
  },
  {
    "ID": "18",
    "STATE_CODE": "KY",
    "STATE_NAME": "Kentucky"
  },
  {
    "ID": "19",
    "STATE_CODE": "LA",
    "STATE_NAME": "Louisiana"
  },
  {
    "ID": "20",
    "STATE_CODE": "ME",
    "STATE_NAME": "Maine"
  },
  {
    "ID": "21",
    "STATE_CODE": "MD",
    "STATE_NAME": "Maryland"
  },
  {
    "ID": "22",
    "STATE_CODE": "MA",
    "STATE_NAME": "Massachusetts"
  },
  {
    "ID": "23",
    "STATE_CODE": "MI",
    "STATE_NAME": "Michigan"
  },
  {
    "ID": "24",
    "STATE_CODE": "MN",
    "STATE_NAME": "Minnesota"
  },
  {
    "ID": "25",
    "STATE_CODE": "MS",
    "STATE_NAME": "Mississippi"
  },
  {
    "ID": "26",
    "STATE_CODE": "MO",
    "STATE_NAME": "Missouri"
  },
  {
    "ID": "27",
    "STATE_CODE": "MT",
    "STATE_NAME": "Montana"
  },
  {
    "ID": "28",
    "STATE_CODE": "NE",
    "STATE_NAME": "Nebraska"
  },
  {
    "ID": "29",
    "STATE_CODE": "NV",
    "STATE_NAME": "Nevada"
  },
  {
    "ID": "30",
    "STATE_CODE": "NH",
    "STATE_NAME": "New Hampshire"
  },
  {
    "ID": "31",
    "STATE_CODE": "NJ",
    "STATE_NAME": "New Jersey"
  },
  {
    "ID": "32",
    "STATE_CODE": "NM",
    "STATE_NAME": "New Mexico"
  },
  {
    "ID": "33",
    "STATE_CODE": "NY",
    "STATE_NAME": "New York"
  },
  {
    "ID": "34",
    "STATE_CODE": "NC",
    "STATE_NAME": "North Carolina"
  },
  {
    "ID": "35",
    "STATE_CODE": "ND",
    "STATE_NAME": "North Dakota"
  },
  {
    "ID": "36",
    "STATE_CODE": "OH",
    "STATE_NAME": "Ohio"
  },
  {
    "ID": "37",
    "STATE_CODE": "OK",
    "STATE_NAME": "Oklahoma"
  },
  {
    "ID": "38",
    "STATE_CODE": "OR",
    "STATE_NAME": "Oregon"
  },
  {
    "ID": "39",
    "STATE_CODE": "PA",
    "STATE_NAME": "Pennsylvania"
  },
  {
    "ID": "40",
    "STATE_CODE": "PR",
    "STATE_NAME": "Puerto Rico"
  },
  {
    "ID": "41",
    "STATE_CODE": "RI",
    "STATE_NAME": "Rhode Island"
  },
  {
    "ID": "42",
    "STATE_CODE": "SC",
    "STATE_NAME": "South Carolina"
  },
  {
    "ID": "43",
    "STATE_CODE": "SD",
    "STATE_NAME": "South Dakota"
  },
  {
    "ID": "44",
    "STATE_CODE": "TN",
    "STATE_NAME": "Tennessee"
  },
  {
    "ID": "45",
    "STATE_CODE": "TX",
    "STATE_NAME": "Texas"
  },
  {
    "ID": "46",
    "STATE_CODE": "UT",
    "STATE_NAME": "Utah"
  },
  {
    "ID": "47",
    "STATE_CODE": "VT",
    "STATE_NAME": "Vermont"
  },
  {
    "ID": "48",
    "STATE_CODE": "VA",
    "STATE_NAME": "Virginia"
  },
  {
    "ID": "49",
    "STATE_CODE": "WA",
    "STATE_NAME": "Washington"
  },
  {
    "ID": "50",
    "STATE_CODE": "WV",
    "STATE_NAME": "West Virginia"
  },
  {
    "ID": "51",
    "STATE_CODE": "WI",
    "STATE_NAME": "Wisconsin"
  },
  {
    "ID": "52",
    "STATE_CODE": "WY",
    "STATE_NAME": "Wyoming"
  }
]

export const basePath = () => {
  const domain = document.domain || window.location.host
  const url = domain === 'localhost' ? "http://localhost:3001" : 'https://' + domain
  return url;
};